package net.lab1024.sa.admin.module.business.yct.yctTeeth.controller;

import net.lab1024.sa.admin.module.business.yct.yctTeeth.domain.form.UserAddForm;
import net.lab1024.sa.admin.module.business.yct.yctTeeth.domain.form.UserQueryForm;
import net.lab1024.sa.admin.module.business.yct.yctTeeth.domain.form.UserUpdateForm;
import net.lab1024.sa.admin.module.business.yct.yctTeeth.domain.vo.UserVO;
import net.lab1024.sa.admin.module.business.yct.yctTeeth.service.UserService;
import cn.dev33.satoken.annotation.SaCheckPermission;
import net.lab1024.sa.base.common.annoation.NoNeedLogin;
import net.lab1024.sa.base.common.domain.ResponseDTO;
import net.lab1024.sa.base.common.domain.PageResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * 小程序用戶 Controller
 *
 * @Author zhangben
 * @Date 2024-10-10 13:24:57
 * @Copyright 20241218
 */

@RestController
@Tag(name = "小程序用戶")
public class UserController {

    @Resource
    private UserService userService;

    @Operation(summary = "分页查询 @author zhangben")
    @PostMapping("/userTeeth/queryPage")
    @SaCheckPermission("user:query")
    public ResponseDTO<PageResult<UserVO>> queryPage(@RequestBody @Valid UserQueryForm queryForm) {
        return ResponseDTO.ok(userService.queryPage(queryForm));
    }

    @Operation(summary = "添加 @author zhangben")
    @PostMapping("/userTeeth/add")
    @SaCheckPermission("user:add")
    public ResponseDTO<String> add(@RequestBody @Valid UserAddForm addForm) {
        return userService.add(addForm);
    }

    @Operation(summary = "更新 @author zhangben")
    @PostMapping("/userTeeth/update")
    @SaCheckPermission("user:update")
    public ResponseDTO<String> update(@RequestBody @Valid UserUpdateForm updateForm) {
        return userService.update(updateForm);
    }
    @NoNeedLogin
    @PostMapping("/userTeeth/queryKf")
    public ResponseDTO<List<UserVO>> queryKf(@RequestBody @Valid UserQueryForm queryForm) {
        return ResponseDTO.ok(userService.queryKf(queryForm));
    }

    @NoNeedLogin
    @PostMapping("/userTeeth/queryUser")
    public ResponseDTO<List<UserVO>> queryUser(@RequestBody @Valid UserQueryForm queryForm) {
        return ResponseDTO.ok(userService.queryUser(queryForm));
    }

    @NoNeedLogin
    @PostMapping("/userTeeth/testSendMsg")
    public ResponseDTO<Boolean> testSendMsg() {
        return ResponseDTO.ok(userService.testSendMsg());
    }

}
